package com.itstyle.seckill.util;

import com.google.common.collect.Lists;
import jodd.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author lifujun
 * @description:
 * @date 2024/2/23 11:40
 */
public class ExportUtil {

    @lombok.Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Data{
        private String name;
        private Integer age;
    }

    /**
     * 排序
     */
    public static void testStream(){
        List<Data> list = Lists.newArrayList();
        list.add(new Data("1111",30));
        list.add(new Data("2222",29));
        List<Data> collect = list.stream()
                .filter(ObjectUtils::allNotNull)
                .sorted(Comparator.comparing(Data::getAge))
                .skip(0)
                .limit(1)
                .collect(Collectors.toList());
        System.out.println(collect);

    }

    public static void main(String[] args) {
        testStream();
    }





}
